var flogin = {
	init:function(){
		
	},
	show:function(){
		//弹窗
		var htmlContent = '';
		
		htmlContent += '<form class="login-form" id="login-form-box">';
		
		htmlContent+= '<div class="login-group">';
		htmlContent+= '<label  class="login-title">账号:</label>';
		htmlContent+= '<div class="login-input">';
		htmlContent+= '<input class="input-text" id="username-inp" placeholder="用户名" type="text">';
		htmlContent+= '</div>';
		htmlContent+= '</div>';
		
		htmlContent+= '<div class="login-group">';
		htmlContent+= ' <label  class="login-title">密码:</label>';
		htmlContent+= '<div class="login-input">';
		htmlContent+= '<input class="input-text" id="pass-inp" placeholder="密码" type="password">';
		htmlContent+= '</div>';
		htmlContent+= '</div>';
		
		htmlContent+= '<div class="login-group">';
		htmlContent+= ' <label  class="login-title">&nbsp;</label>';
		htmlContent+= '<div class="login-input login-info">';
		htmlContent+= '<a href="http://www.gzcanr.com/cooperate/index-cmd-strategy.html" class="info-href" >没有账号，立即申请</a>';
		htmlContent+= '</div>';
		htmlContent+= '</div>';
		
		
		htmlContent+= ' </form>';
	
		layer.open({
		  type: 1,
		  title: '报价系统登录',
		  closeBtn: 1,
		  btnAlign: 'c', //按钮居中
		  btn: ['登录', '取消'],
		  area: ['500px', '300px'],
		  shadeClose: true,
		  content: htmlContent,
		  yes: function(){
             flogin.submitdo();
          },
		  success:function(layero, index){
			  $(document).bind('keydown', function(e){
                if(e.keyCode == 13){
                    flogin.submitdo();
                }
              });
		  },
		  cancel:function(layero, index){
			  $(document).unbind("keydown");
		  },
		  end:function(layero, index){
			  $(document).unbind("keydown");
		  }
		});
	},
	submitdo:function(){
		var $username = $('#username-inp');
		var $password = $('#pass-inp');
		var nameVal = passVal = '';
		nameVal = $.trim($username.val());
		passVal = $.trim($password.val());
		if(nameVal==''){
			alert('请输入用户名!');
			$username.focus();
			return false;
		}
		if(passVal==''){
			alert('请输入密码!');
			$password.focus();
			return false;
		}
		//报价处理
		$.post("/front/login.html",{'uname':nameVal,'upass':passVal},function(data) {
			   if(data=='ok'){
				   document.location.href = "http://www.gzcanr.com/cooperate/myQuoted.html";
				   layer.closeAll();
			   }else if(data=='error'){
				   alert('登录失败');
			   }
			   else if(data=='error_num'){
				   alert('登录过于频繁,请稍等再试！');
			   }
			   else if(data=='error_user'){
				   alert('该用户不存在,请重新输入！');
			   }
			   else if(data=='error_pass'){
				   alert('密码错误,请重新输入！');
			   }
		});
	}
	
}

// document init
$(function() {
	
});